package com.seashop.feign.fallback;

import com.seashop.feign.ThirdFeignClient;
import com.seashop.request.GoogleTransRequestParam;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author moredln
 * @desc 三方服务调用失败处理
 * @date 2020-11-11 10:32
 */
@Component
@Slf4j
public class ThirdFeignClientFallBack implements FallbackFactory<ThirdFeignClient> {
    @Override
    public ThirdFeignClient create(Throwable throwable) {
        return new ThirdFeignClient(){
            @Override
            public String batchTrans(GoogleTransRequestParam param) {
                log.info("调用三方服务批量翻译失败");
                return null;
            }

            @Override
            public String googleTrans(String text, String fromLanguageType, String toLanguageType) {
                log.info("调用三方服务谷歌翻译失败");
                return null;
            }
        };
    }
}
